package com.nycreativity.elecreativity.service;

import com.baomidou.mybatisplus.core.metadata.IPage
import com.baomidou.mybatisplus.extension.service.IService;
import com.nycreativity.elecreativity.entity.dto.SkuSpecificationDTO
import com.nycreativity.elecreativity.entity.param.sku.SkuAddParam
import com.nycreativity.elecreativity.entity.param.sku.SkuQueryParam
import com.nycreativity.elecreativity.entity.param.sku.SkuUpdateParam
import com.nycreativity.elecreativity.entity.po.Sku
import com.nycreativity.elecreativity.entity.vo.goods.SkuOfGoodsVO
import com.nycreativity.elecreativity.entity.vo.sku.SkuVO
import org.springframework.web.multipart.MultipartFile

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author sxt && ttxxi
 * @since 2021-03-22
 */
interface SkuService : IService<Sku> {

    /**
     * 新增sku
     */
    fun addSku(files: Array<MultipartFile>, skuAddParam: SkuAddParam): Boolean

    /**
     * 根据条件分页查询sku
     */
    fun queryPageByCondition(skuQueryParam: SkuQueryParam): IPage<SkuVO>

    /**
     * 根据规格查询sku
     */
    fun queryByGoodsIdAndSpecification(goodsId: Long, skuSpecificationDTO: SkuSpecificationDTO): List<SkuVO>?

    /**
     * 根据goodsId修改sku的规格
     * @param target 0:size  1:color
     */
    fun updateSpecificationByGoodsId(target: Int, goodsId: Long, oldOne: String, newOne: String)

    /**
     * 根据goodsId查询sku
     */
    fun queryByGoodsId(goodsId: Long): List<SkuVO>

    /**
     * 根据id更新
     */
    fun updateById(skuUpdateParam: SkuUpdateParam): Boolean

    /**
     * 根据索引删除sku的图片
     */
    fun deleteImage(skuId: Long, indexArray: IntArray)

    /**
     * 上传图片，建议只在service层使用
     * @return 图片地址list
     */
    fun uploadImage(skuId: Long, files: Array<MultipartFile>): List<String>

    /**
     * 上传新的图片，不要用混了
     */
    fun uploadNewImage(skuId: Long, files: Array<MultipartFile>): Boolean

    /**
     * 根据id删除
     */
    fun deleteById(id: Long)

    /**
     * 查询商品对应的规格信息
     * @param goodsId Long 商品id
     * @return GoodsSpecificationDTO 商品对应的规格信息
     */
    fun queryGoodsSpecification(goodsId: Long): List<SkuOfGoodsVO>

}
